<template>
	<view>
		<view class="notice-item-rich" v-for="(gift,index) in giftList" :key="index" @click="clickGiftRich(gift)">
			<text class="time">{{ gift.createTime }}</text>
			<view class="content">
				<text class="title">{{ gift.name }}</text>
				<view class="img-wrapper-rich">
					<image class="pic" :src="gift.image" mode="aspectFit"></image>
				</view>
				<!-- #ifndef MP -->
				<view class="bot-rich">
					<text>点击领取</text>
					<text class="more-icon yticon icon-you"></text>
				</view>
				<!--  #endif -->
				<!-- #ifdef MP -->
				<view class="bot-rich">
					<text>点击复制链接：{{gift.linkUrl}}</text>
				</view>
				<!--  #endif -->
			</view>
		</view>
		<view class="notice-item-rich" v-if="giftList.length === 0" style="margin-top: 30px">
			<text>暂无权益包信息</text>
		</view>
	</view>
</template>

<script>
	import {
		request,
		getUserId
	} from '@/utils';
	export default {
		data() {
			return {
				giftList: [],
				
				
				//下面是没用的垃圾混淆代码
				renzhengTimeSta1111111: true, //初次请求认证时间默认是带有的，
				zhuceTimeSta11111: false, //初次请求注册时间默认是没有的
				renzhengTimeList11111: [],
				zhuceTimeStaList1111: null,
				detailOrderIdStr11111: '',
				threeTabCurrent1111: 0,
				applyGOodsList11111: [], //供货商列表
				allCardEnterSta1111: false, //默认是false，点击批量卡券入库的时候变为true
				codeAddNumsList11111: [],
				numsList11111: [],
				dataSourceBqcp1111: [],
				selectedRowKeys1111: [],
				selectedRowKeysB11111: [],
				rkVisible11111: false,
				rkjlVisible1111: false,
				lhjlVisible1111: false,
				currentStyleData22222: {},
				dataSourceStyle2222: [],
				showStyleData2222: false,
				indexTemplate2222: [],
				SVGCircleElement3ee: '',
				vshoweqwsc1111: false,
				showStyleDataInfo2222: false,
				opeCategoryList2222: [],
				leimuVisible2222: false,
				selectedRowKeys02222: [],
				selectionRows02222: [],
				selectedRowKeys133333: [],
				selectionRows13333: [],
				selectedRowKeys2333: [],
				selectionRows23333: [],
				selectedRowKeys33333: [],
				selectionRows33333: [],
				selectedRowKeys4333: [],
				selectionRows43333: [],
				curwfqwrentStyleDaterwaInfo444: {},
				currwerentStywerleDatweraInfo1444: {},
				currewerntStyleDataInfo24444: {},
				currentweStyleDytuataIwenfo34444: {},
				currenwetStdfgyleDataInfo44444: {},
				checkZfbPhone_h5444: '',
				plNafgdvfdtjyme4444: '', //四大品类的名字
				uniPdfgrtylatform444: '', //运行环境mp-alipay mp-weixin
				refgjtytrsemark555: '', //备注
				timefgjSelStr5555: '', //选择的上门时间（2023-08-31 00:00:00）
				amOdcuiofasrpm5555: '', //选择的上门时间是上午还是下午
				pageShnjlkgohowTime5555: '', //页面上用户看到的显示的时间
				paraghsdfmsw454: {},
				valhgujtueNum56756: 0,
				addrdraess56756: {}, //上门收货地址
				adawerterydressId575: 0,
				sceoyuitne57567: '',
				tntuiopId56757: '',
				weictyuratCustomer5756: '',
				yuidurtyuoy567567: false,
				
				
				//下面是没用的垃圾混淆代码
				renzhengTimeSta1111111: true, //初次请求认证时间默认是带有的，
				zhuceTimeSta11111: false, //初次请求注册时间默认是没有的
				renzhengTimeList11111: [],
				zhuceTimeStaList1111: null,
				detailOrderIdStr11111: '',
				threeTabCurrent1111: 0,
				applyGOodsList11111: [], //供货商列表
				allCardEnterSta1111: false, //默认是false，点击批量卡券入库的时候变为true
				codeAddNumsList11111: [],
				numsList11111: [],
				dataSourceBqcp1111: [],
				selectedRowKeys1111: [],
				selectedRowKeysB11111: [],
				rkVisible11111: false,
				rkjlVisible1111: false,
				lhjlVisible1111: false,
				currentStyleData22222: {},
				dataSourceStyle2222: [],
				showStyleData2222: false,
				indexTemplate2222: [],
				SVGCircleElement3ee: '',
				vshoweqwsc1111: false,
				showStyleDataInfo2222: false,
				opeCategoryList2222: [],
				leimuVisible2222: false,
				selectedRowKeys02222: [],
				selectionRows02222: [],
				selectedRowKeys133333: [],
				selectionRows13333: [],
				selectedRowKeys2333: [],
				selectionRows23333: [],
				selectedRowKeys33333: [],
				selectionRows33333: [],
				selectedRowKeys4333: [],
				selectionRows43333: [],
				curwfqwrentStyleDaterwaInfo444: {},
				currwerentStywerleDatweraInfo1444: {},
				currewerntStyleDataInfo24444: {},
				currentweStyleDytuataIwenfo34444: {},
				currenwetStdfgyleDataInfo44444: {},
				checkZfbPhone_h5444: '',
				plNafgdvfdtjyme4444: '', //四大品类的名字
				uniPdfgrtylatform444: '', //运行环境mp-alipay mp-weixin
				refgjtytrsemark555: '', //备注
				timefgjSelStr5555: '', //选择的上门时间（2023-08-31 00:00:00）
				amOdcuiofasrpm5555: '', //选择的上门时间是上午还是下午
				pageShnjlkgohowTime5555: '', //页面上用户看到的显示的时间
				paraghsdfmsw454: {},
				valhgujtueNum56756: 0,
				addrdraess56756: {}, //上门收货地址
				adawerterydressId575: 0,
				sceoyuitne57567: '',
				tntuiopId56757: '',
				weictyuratCustomer5756: '',
				yuidurtyuoy567567: false,
			};
		},
		onLoad() {
			this.getUserGiftListRich();
		},

		methods: {
			getUserGiftListRich() {
				uni.showLoading({
					title: '加载中'
				});
				request(
						'member/mall/alipay/gift/getUserGift', {},
						'GET'
					)
					.then((res) => {
						this.giftList = res.data;
					})
					.finally(() => uni.hideLoading());
			},

			//领取权益
			clickGiftRich(gift) {
				let linkUrl = gift.linkUrl || 'https://www.baidu.com';
				if (!linkUrl) {
					uni.showToast({
						title: '无效跳转地址！',
						icon: 'none'
					});
					return;
				}
				request(
					'member/mall/alipay/gift/updateUserGiftStatus', {
						uid: getUserId(),
						id: gift.id
					},
					'POST'
				).then((res) => {
					if (res.businessSuccess) {
						// 仅在app中运行，且调用plus这个api
						// #ifdef APP-PLUS
						plus.runtime.openURL(linkUrl, function(err) {
							uni.showToast({
								title: JSON.stringify(err),
								duration: 8000
							});
						});
						// #endif
						// #ifdef H5
						// window.open(linkUrl);
						window.location.href = linkUrl;
						// #endif
						// #ifdef MP
						uni.setClipboardData({
							data: linkUrl,
							success: (r) => {
								uni.showToast({
									title: '复制链接成功!请到浏览器中打开',
									icon: 'none'
								});
							}
						});
						// #endif
					} else {
						uni.showToast({
							title: res.errorMessage,
							icon: 'none'
						});
					}
				});
			}
		}
	};
</script>

<style lang="scss">
	page {
		background-color: #f7f7f7;
		padding-bottom: 30upx;
	}

	.notice-item-rich {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.time {
		font-size: 26upx;
		color: #7d7d7d;
		height: 80upx;
		padding-top: 10upx;
		display: flex;
		align-items: center;
		justify-content: center;

	}

	.content {
		overflow: hidden;
		border-radius: 18upx;
		box-shadow: 0 6rpx 20rpx 0 rgba(0, 0, 0, 0.1);
		width: 90%;
		padding: 10rpx 30upx 0;
		background-color: #fff;

	}

	.title {
		font-size: 32upx;
		color: #303133;
		height: 60upx;
		display: flex;
		align-items: center;
		line-height: 60upx;

	}

	.img-wrapper-rich {
		position: relative;
		width: 100%;
		height: 400upx;
		margin-bottom: 20rpx;
	}

	.pic {
		width: 100%;
		height: 100%;
		display: block;
		border-radius: 6upx;
	}

	.cover {
		background-color: rgba(0, 0, 0, 0.5);
		font-size: 36upx;
		color: #fff;
		width: 100%;
		height: 100%;
		position: absolute;
		left: 0;
		top: 0;
		display: flex;
		justify-content: center;
		align-items: center;

	}

	.introduce {
		line-height: 38upx;
		display: inline-block;
		padding: 16upx 0;
		font-size: 28upx;
		color: #606266;
	}

	.bot-rich {
		color: #707070;
		height: 80upx;
		font-size: 24upx;
		position: relative;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.more-icon {
		font-size: 32upx;
	}
</style>